﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace KeyCtrl
{
    class Utils
    {
        static public String TrimLast(String inp)
        {
            if (inp == "")
                return "";
            
            return inp.Remove(inp.Length - 1);
        }

        [DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")]
        public static extern IntPtr CreateRoundRectRgn
        (
            int nLeftRect, // x-coordinate of upper-left corner
            int nTopRect, // y-coordinate of upper-left corner
            int nRightRect, // x-coordinate of lower-right corner
            int nBottomRect, // y-coordinate of lower-right corner
            int nWidthEllipse, // height of ellipse
            int nHeightEllipse // width of ellipse
        );

        static public void SetRoundedCorners(System.Windows.Forms.Form form)
        {
            form.Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0,
                form.Width - 10, form.Height - 10, 20, 20));
        }
    }
}
